package org.ww.edu.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.ww.commonutils.R;
import org.ww.edu.bean.Course;
import org.ww.edu.bean.Teacher;
import org.ww.edu.service.CourseService;
import org.ww.edu.service.TeacherService;

import java.util.List;

@RestController
@RequestMapping("/edu/indexfront")
//@CrossOrigin
public class IndexFrontController {

    @Autowired
    private CourseService courseService;

    @Autowired
    private TeacherService teacherService;

    /**
     * 根据id降序排列，查询前8条课程信息，前4条教师信息
     * @return
     */
    @GetMapping("index")
    public R index(){
        //查询前8条课程信息
        List<Course> courseList=courseService.getHotCourse();
        //查询前4条教师信息
        List<Teacher> teacherList=teacherService.getHotTeacher();


        return R.ok().data("courseList",courseList).data("teacherList",teacherList);
    }
}
